﻿/**
* @projectName   cvvision
* @file          IBLLOperator.h
* @brief         通用业务操作接口类 所有通用业务处理均继承此类 比如：输入输出/格式化/网络等
* @author        GuoFeng
* @contact        805305774@qq.com/feng.guo@micro-i.com.cn
* @date          2022-03-08
*/

#ifndef IBLLOPERATOR_H
#define IBLLOPERATOR_H

#include <QObject>
#include <QMutex>

#include "Interface_Global.h"
#include "IPluginParam.h"


namespace CVV {
namespace Interface {


class INTERFACE_EXPORT IBLLOperator : public QObject
{
    Q_OBJECT
public:
    explicit IBLLOperator(QObject *parent = nullptr);
    virtual ~IBLLOperator() = 0;

    /**
     * @brief run 执行接口
     * @param param
     * @return
     */
    virtual bool run(std::shared_ptr<CVV::Interface::IPluginParam> param) = 0;
    /**
     * @brief init 暂时针对网络插件进行发送启动服务信号
     * @param param
     * @return
     */
    virtual bool init(const QString &engineKey, std::shared_ptr<CVV::Interface::IPluginParam> param);
    /**
     * @brief getBLLParam
     * @return
     */
    virtual std::shared_ptr<IPluginParam> getBLLParam();

    /**
     * @brief initParam
     * @param mapInOutParam
     */
    virtual void initParam(const QMap<QString, std::shared_ptr<CVV::Interface::IPluginParam>> &mapInOutParam);

protected:
    /**
     * @brief getValue
     * @param strPath
     * @return
     */
    QVariant getValue(const QString& strPath);

signals:
    /**
     * @brief sigStartNetService 发送启动网络服务信号
     * @param port
     */
    void sigStartNetService(const QString &engineKey, int port);
    /**
     * @brief sigInspectResultReady 执行完方案:数据发送插件调用信号触发把格式化的检测Json数据发送出来
     * @param imgHeader 图片头部信息
     * @param jsonRes  检测缺陷结果
     */
    void sigInspectResultReady(const QString &imgHeader,const QString & jsonRes);

protected:
    QMap<QString, std::shared_ptr<CVV::Interface::IPluginParam>> m_mapInOutParam;
    QMutex m_mutex;

};

}
}

#endif // IBLLOPERATOR_H
